package com.project.yuepai.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.yuepai.dao.SuggestMapper;
import com.project.yuepai.dto.FeedbackDto;
import com.project.yuepai.service.SuggestService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
public class SuggestServiceImpl implements SuggestService{

    @Resource
    private SuggestMapper suggestMapper;

    @Override
    public PageInfo<FeedbackDto> listFeedback(Integer page, Integer limit, String nickName,Integer userRole,String userPhone) {
        PageHelper.startPage(page,limit);
        System.out.println("获取到的-->"+suggestMapper.findAllFeedback(nickName,userRole,userPhone));
        return new PageInfo<FeedbackDto>(suggestMapper.findAllFeedback(nickName,userRole,userPhone));
    }

    @Transactional
    @Override
    public boolean deleteFeedback(Integer feedbackId) {
        if(suggestMapper.deleteFeedback(feedbackId)==1){
            if(suggestMapper.deleteFeedbackInRelation(feedbackId)==1)
                return true;
        }
        return false;
    }
}
